package ru.pb.game.network.engine.auth.packets.sendable;

import ru.pb.game.configs.GameNetworkConfig;
import ru.pb.game.configs.GameServerConfig;
import ru.pb.game.data.xml.holders.IPSystemHolder;
import ru.pb.game.network.engine.auth.packets.GameServerToAuthServerPacket;
import ru.pb.global.network.IPRange;

public class AUTH_REQUEST extends GameServerToAuthServerPacket
{
	@Override
	public void writeImpl()
	{
		writeH(0x01);
		writeC(GameServerConfig.ID);
		writeS(GameServerConfig.PASSWORD, 32);
		writeH(GameNetworkConfig.CLIENT_LISTENER_PORT);
		writeH(GameServerConfig.MAX_PLAYERS);
		writeBoolC(GameServerConfig.IS_GM_ONLY);

		writeD(IPSystemHolder.getInstance().get().size());
		for(IPRange ip : IPSystemHolder.getInstance().get())
		{
			byte[] min = ip.getMinAsByteArray();
			byte[] max = ip.getMaxAsByteArray();
			writeC(min.length);
			writeB(min);
			writeC(max.length);
			writeB(max);
			writeC(ip.getAddress().length);
			writeB(ip.getAddress());
		}
	}
}